package cqie.personal.frame.controller;


import cqie.personal.frame.bo.GetDepartmentBO;
import cqie.personal.frame.entity.DepartmentInfo;
import cqie.personal.frame.enums.Code;
import cqie.personal.frame.exception.ValidationFailException;
import cqie.personal.frame.service.DepartmentInfoService;
import cqie.personal.frame.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Yeeeeee
 * @since 2021-09-27
 */
@RestController
@Api(tags = "部门操作公共模块")
@RequestMapping("/department-info")
public class DepartmentInfoController {

    @Resource
    private DepartmentInfoService departmentInfoService;


    @ApiOperation("查询所有部门")
    @GetMapping("/getDepartment")
    public ResultVO getDepartment(GetDepartmentBO departmentBO) throws ValidationFailException {
        List<DepartmentInfo> result = departmentInfoService.getDepartment(departmentBO);
        if(result==null||result.size()<1){
            return new ResultVO(Code.NULL_DATA.getCode(),Code.NULL_DATA.getMessage());
        }
        return new ResultVO(result);
    }

}

